package com.example.yiparkapplication.activity.index.activity.discountCard;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.yiparkapplication.R;
import com.example.yiparkapplication.activity.index.activity.StaffQuery.StaffQueryActivity;

public class DiscountCardNoteStreetNameAdapter extends RecyclerView.Adapter<DiscountCardNoteStreetNameAdapter.ViewHolder> {
    private String[] mStreetNames;
    private StaffQueryActivity mStaffQueryActivity;

    public static class ViewHolder extends RecyclerView.ViewHolder{
        View streetNameView;
        TextView streetName;

        public ViewHolder(View view){
            super(view);
            streetNameView = view;
            streetName = view.findViewById(R.id.id_one_text_info);
        }
    }

    public DiscountCardNoteStreetNameAdapter(String[] streetName){
        mStreetNames = streetName;
    }

    public DiscountCardNoteStreetNameAdapter(String[] streetName, StaffQueryActivity staffQueryActivity){
        mStreetNames = streetName;
        mStaffQueryActivity = staffQueryActivity;
    }

    @Override
    public DiscountCardNoteStreetNameAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType){
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.fragment_street_name_layout, parent, false);
        final DiscountCardNoteStreetNameAdapter.ViewHolder holder = new DiscountCardNoteStreetNameAdapter.ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull DiscountCardNoteStreetNameAdapter.ViewHolder holder, int position){
        String streetName = mStreetNames[position];
        holder.streetName.setText(streetName);
        if (mStaffQueryActivity != null){
            holder.streetName.setTextColor(mStaffQueryActivity.getResources().getColor(R.color.color_blue_61a4ff));
        }
    }

    @Override
    public int getItemCount(){
        return mStreetNames.length;
    }

}
